<template>
  <vxe-input
    v-model="propData.value"
    class="sn-fixed-str"
    placeholder="请输入固定字符"
    @blur="handleInput"
  />
</template>

<script lang="ts" setup>
import { SnWidgetDataType } from '@/components/FormCreate/src/config/SerialNumber/UseSerialNumberRule'
import { generateUUID, toAnyString } from '@/utils'
import { useApprovalDesignerStore } from '@/store/modules/dsgn/ApprovalDesigner'

const props = defineProps<{
  modelValue: SnWidgetDataType
}>()

const propData = ref(props.modelValue)

const designerStore = useApprovalDesignerStore()

const emit = defineEmits(['update:data'])

const handleInput = () => {
  let val = propData.value.value
  emit('update:data', {
    label: val,
    value: val
  })
}

if (propData.value.value === '') {
  // propData.value.value = generateUUID()
  propData.value.value = designerStore.designerModel.basic.title
  handleInput()
}

</script>

<style scoped>
.sn-fixed-str {
  margin: 5px;
  padding: 5px;
  border: 1px solid #ccc;
  display: inline-block;
}
</style>
